package com.video.web.controller.video;

import com.video.video.domain.dto.HtDOrderRecordDto;
import com.video.video.domain.vo.DOrderQuery;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.video.common.annotation.Log;
import com.video.common.core.controller.BaseController;
import com.video.common.core.domain.AjaxResult;
import com.video.common.enums.BusinessType;
import com.video.video.domain.DOrderRecord;
import com.video.video.service.IDOrderRecordService;
import com.video.common.utils.poi.ExcelUtil;
import com.video.common.core.page.TableDataInfo;

/**
 * 订单下载记录Controller
 *
 * @author ruoyi
 * @date 2022-09-27
 */
@RestController
@RequestMapping("/video/DOrderRecord")
public class DOrderRecordController extends BaseController
{
    @Autowired
    private IDOrderRecordService dOrderRecordService;

    /**
     * 查询订单下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(DOrderQuery query)
    {
        startPage();
        List<HtDOrderRecordDto> list = dOrderRecordService.selectHtDOrderRecordDtoList(query);
        return getDataTable(list);
    }

    /**
     * 导出订单下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:export')")
    @Log(title = "订单下载记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DOrderQuery query)
    {
        List<HtDOrderRecordDto> list = dOrderRecordService.selectHtDOrderRecordDtoList(query);
        ExcelUtil<HtDOrderRecordDto> util = new ExcelUtil<HtDOrderRecordDto>(HtDOrderRecordDto.class);
        util.exportExcel(response, list, "订单下载记录数据");
    }

    /**
     * 获取订单下载记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dOrderRecordService.selectDOrderRecordById(id));
    }

    /**
     * 新增订单下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:add')")
    @Log(title = "订单下载记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DOrderRecord dOrderRecord)
    {
        return toAjax(dOrderRecordService.insertDOrderRecord(dOrderRecord));
    }

    /**
     * 修改订单下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:edit')")
    @Log(title = "订单下载记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DOrderRecord dOrderRecord)
    {
        return toAjax(dOrderRecordService.updateDOrderRecord(dOrderRecord));
    }

    /**
     * 删除订单下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:DOrderRecord:remove')")
    @Log(title = "订单下载记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dOrderRecordService.deleteDOrderRecordByIds(ids));
    }
}
